//
//  GYMainViewController.swift
//  Weibo
//
//  Created by vane on 16/8/9.
//  Copyright © 2016年 apple. All rights reserved.
//

import UIKit

class GYMainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let tabBar = GYTabBar()
        
        tabBar.gyDelegate = self
        
        setValue(tabBar, forKey: "tabBar")
        
        addChildViewController(GYHomeViewController(), title: "首页", imgName: "tabbar_home")
        addChildViewController(GYMessageViewController(), title: "消息", imgName: "tabbar_message_center")
        addChildViewController(GYDiscoverViewController(), title: "发现", imgName: "tabbar_discover")
        addChildViewController(GYProfileViewController(), title: "我de", imgName: "tabbar_profile")
        
    }
    private  func addChildViewController(vc: UIViewController,title:String,imgName:String) {
        
        addChildViewController(UINavigationController(rootViewController: vc))
        vc.title = title
        vc.tabBarItem.image = UIImage(named: imgName)
        vc.tabBarItem.selectedImage = UIImage(named: "\(imgName)_selected")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        vc.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName: AppThemeColor], forState: UIControlState.Selected)

    }
    
}
extension GYMainViewController:GYTabBarDelegate{
    
    func tabBarButtonClick() {
        
        print("xxxxx")
        
        if !GYUserAccountViewModel.sharedTools.isLogin{
            
            print("请登录")
            return
        }
        
        presentViewController(UINavigationController(rootViewController: GYComposeViewController()), animated: true, completion: nil)
    }
    
}